package com.borqs.samples;

import android.util.*;
import android.os.*;
import android.net.NetworkStats;
import com.android.internal.net.NetworkStatsFactory;

public class NetworkSampler extends ASampler{
    private final static String TAG = "NetworkSampler";
    private NetworkStatsFactory mNetworkStatsFactory; 
    private NetworkStats mNetworkSummaryCache;

    public NetworkSampler(DBHelper helper){
        super(helper);
        mNetworkStatsFactory = new NetworkStatsFactory();
    }
    @Override public void sample(long sampletime){
    }
    private void networkSummay(){
        try {
            mNetworkSummaryCache = mNetworkStatsFactory.readNetworkStatsSummary();
            final long totalTxBytes = mNetworkSummaryCache.getTotal(null).txBytes;
            final long totalRxBytes = mNetworkSummaryCache.getTotal(null).rxBytes;
            Log.d(TAG,"totalTxBytes="+totalTxBytes+",totalRxBytes="+totalRxBytes);
        } catch (IllegalStateException e) {
            // log problem and return empty object
            Log.wtf(TAG, "problem reading network stats", e);
            mNetworkSummaryCache = new NetworkStats(SystemClock.elapsedRealtime(), 0);
        }
    }
}
